<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header ("Pragma: no-cache");
header("Expires: 0"); 




include_once "xAP-functions/webincludes.php";
$id=intval($_GET["id"]);
$time=intval($_GET["time"])-2;

$results=dbquery("SELECT xap_iphone_item.ItemID,xAP_Device.xtype,xAP_Device.xvalue,xAP_Device.xvalue2,xAP_Device.xvalue3,xAP_Device.xvalue4,xAP_Device.xvalue5 FROM xap_iphone_item 
Left Outer Join xAP_Device ON xAP_Iphone_item.DeviceID=xAP_Device.DeviceID
where xap_iphone_item.screenid=".$id." and Updated>='".date("Y-m-d H:i:s",$time)."'");

//echo date("Y-m-d H:i:s",$time);
//print_r($results);
if(isset($results )){
	foreach($results as $v){
		$item[$v["ItemID"]]="<img src='/Floorplan/iphoneimages/lamp_".$v["xvalue"].".png'><BR>Main Lamp";
	}
}


echo time()."~~~";
if(isset($item )){
	foreach($item as $k=>$v){
		echo $k."###".$v."~~~";
	}
}
?>
